package org.summerframework.core.config;

import org.summerframework.core.util.SpringContextUtil;
import org.summerframework.core.util.UrlUtil;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.*;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @author 石超
 * @version v1.0.0
 */
@Configuration
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@ComponentScan("org.summerframework.core")
public class SpringContextConfig {

    @Bean
    @Lazy(false)
    @ConditionalOnMissingBean
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    public SpringContextUtil springContextUtil() {
        return new SpringContextUtil();
    }

    @Bean
    @Lazy(false)
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    public UrlUtil urlUtil(ConfigurableEnvironment environment) {
        return new UrlUtil(environment);
    }
}
